package com.ibeetl.cms.service;

import java.util.List;

import com.ibeetl.cms.entity.IndustrialTalents;
import com.ibeetl.cms.entity.Renting;
import com.ibeetl.cms.entity.TelentCard;
import org.beetl.sql.core.engine.PageQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ibeetl.admin.core.util.PlatformException;

import com.ibeetl.cms.dao.QuitDao;
import com.ibeetl.cms.entity.Quit;
import com.ibeetl.admin.core.service.BaseService;

/**
 * Quit Service
 */

@Service
@Transactional
public class QuitService extends BaseService<Quit>{

    @Autowired
    private QuitDao quitDao;

    public PageQuery<Quit>queryByCondition(PageQuery query){
        PageQuery ret =  quitDao.queryByCondition(query);
        queryListAfter(ret.getList());
        return ret;
    }

    public void batchDelQuit(List<Long> ids){
        try {
            quitDao.batchDelQuitByIds(ids);
        } catch (Exception e) {
            throw new PlatformException("批量删除Quit失败", e);
        }
    }
    //查企业
    public PageQuery<Quit>findenterprise(PageQuery query){
        PageQuery ret =  quitDao.findenterprise(query);
        queryListAfter(ret.getList());
        return ret;
    }

    //查询是否存在人才卡
    public TelentCard talentCardIsNull(Integer userId){
        return quitDao.talentCardIsNull(userId);
    }

    //查询人才卡积分
    public int talentCardGetScore(Integer userId){
        return quitDao.talentCardGetScore(userId);
    }

    //查询此用户是否离职
    public Boolean notLeave(Long userId,Long companyId){
        return quitDao.notLeave(userId,companyId)>0;
    }

    //查询本年度是否已申报
    public Boolean judgeYear(String declarationType,Integer userId,Integer year){
        return quitDao.judgeYear(declarationType,userId,year)>0;
    }

    //查询人才卡是否过期
    public Boolean talentCardOverdue(Integer userId){
        return quitDao.talentCardOverdue(userId)>0;
    }

    public PageQuery<Quit> queryDoneTask(PageQuery page) {
        PageQuery ret =  quitDao.queryDoneTask(page);
        queryListAfter(ret.getList());
        return ret;

    }
    public Boolean updateCompanyId(Integer userId){//
        return quitDao.updateCompanyId(userId)>0;
    }
}